# Euler Problem 2
# Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.

#################################
cycles = 100000
cycles = 1
import time
c1 = time.clock()
for x in xrange(0xFFFFF): pass
for i in range(cycles):
    answer = 0
#################################
### program calculation start ###
#################################

    ## runs in 0.04 ms (100k cycles)
    fiboold = 1
    fibo = 2

    while fibo < 4e6:
        answer = answer + fibo
        
        for i in range(3):                
            fibonewold = fibo
            fibo = fibo + fiboold
            fiboold = fibonewold       

#################################
###  program calculation end  ###
#################################
c2 = time.clock()
if cycles > 1: print "Time spent is %.2f ms" % ((c2-c1)*1000/cycles)
#################################
        
print 'The answer to Problem #2 is >>', answer, '<<'

        